package com.hu.zhcc.shiro.controller;

import com.github.pagehelper.PageInfo;
import com.hu.zhcc.common.entity.Page;
import com.hu.zhcc.shiro.entity.bo.Emp;
import com.hu.zhcc.shiro.entity.vo.UserListVO;
import com.hu.zhcc.shiro.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/emp")
public class EmpController {
    @Autowired
    EmpService empService;
    @GetMapping("listAllEmp")
    public ResponseEntity<PageInfo<Emp>> getUserList(@RequestParam(required = false) String name,
                                                        @RequestParam(required = false) String sort, int offset, int limit) {
        PageInfo<Emp> allEmp = empService.listAllEmp(offset, limit);
        return ResponseEntity.ok(allEmp);
    }
    @GetMapping("getEmp")
    public ResponseEntity<Emp> getEmp(Integer id) {
        Emp emp = empService.getEmp(id);
        return ResponseEntity.ok(emp);
    }
    @PostMapping("updateEmp")
    public ResponseEntity<String> updateEmp(Integer id, Emp emp) {
        String s = empService.updateEmp(id, emp);
        return ResponseEntity.ok(s);
    }
}
